This page last changed on Dec 19, 2007 by jdeolive.

GetFeature GET extensions

GetFeature GET allows the filter to be speficied in CQL. CQL sports a much more compact and human readable syntax compared to OGC filters, but cannot encode as many filters as OGC spec does. In particular, FID filters are not supported at the time of writing.

Sample request follow (requests has been split over multiple lines for better readability and URL-encoded as per HTTP specification).

Sample in OGC filter encoding:

http://localhost:8080/wfs?
request=GetFeature
&typeName=topp:states
&outputFormat=GML2
&FILTER=%3CFilter%20xmlns:gml=%22http://www.opengis.net/gml%22%3E%3CIntersects%3E%3CPropertyName%3Ethe_geom%3C/PropertyName%3E
%3Cgml:Point%20srsName=%224326%22%3E%3Cgml:coordinates%3E-74.817265,40.5296504%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E

Same request, but encoded in CQL:

http://localhost:8080/wfs?
request=GetFeature&
typeName=topp:states&
outputFormat=GML2&
CQL_FILTER=INTERSECT(the_geom,%20POINT%20(-74.817265%2040.5296504))

WFS 1.0 reprojection

One of the most interesting features of WFS 1.1 is the ability to reproject data on the fly, that is, have the data natively in on SRS and gather GML back in another SRS.

GeoServer does support this ability on WFS 1.0 too. When doing a WFS 1.0 GetFeature GET request you can add the &srsName=srsName parameter to specify the reprojection SRS, whilst for posts requests you can add an srsName="srsName" attribute to the Query element for the same purpose.

XML Request Validation

As of 1.6.0, a strict flag was added for validating XML requests. When set to true, XML validation is set on incoming WFS XML requests. Consider the following request:

<wfs:GetFeature service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs">
  <Query typeName="topp:states"/>
</wfs:GetFeature>

Technically this request is "invalid" for the following reasons:

  • The "Query" element should be prefixed with "wfs"
  • The "topp" prefix has not been mapped to a namespace uri

Executing this request normally works just fine:

% curl -H 'Content-type: text/xml' 
    -d "<wfs:GetFeature xmlns:wfs='http://www.opengis.net/wfs' service='WFS' version='1.0.0'><Query typeName='topp:states'/></wfs:GetFeature>" 
    http://localhost:8080/geoserver/wfs

<wfs:FeatureCollection ...

However, executing with the strict flag set to "true" results in an error:

% curl -H 'Content-type: text/xml' 
    -d "<wfs:GetFeature xmlns:wfs='http://www.opengis.net/wfs' service='WFS' version='1.0.0'><Query typeName='topp:states'/></wfs:GetFeature>"
    http://localhost:8080/geoserver/wfs?strict=true

<ServiceExceptionReport>
 <ServiceException code="InvalidParameterValue">
      Invalid request
TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.opengis.net/wfs'.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'Query'. One of '{"http://www.opengis.net/wfs":Query}' is expected.
TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.opengis.net/wfs'.
</ServiceException>
</ServiceExceptionReport>

Fixing the request:

<wfs:GetFeature service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp">
  <wfs:Query typeName="topp:states"/>
</wfs:GetFeature>

And executing again with the strict flag set to "true" everything is ok:

% curl -H 'Content-type: text/xml' 
    -d "<wfs:GetFeature service='WFS' version='1.0.0' xmlns:wfs='http://www.opengis.net/wfs' xmlns:topp='http://www.openplans.org/topp'><Query typeName='topp:states'/></wfs:GetFeature>" 
    http://localhost:8080/geoserver/wfs?strict=true

<wfs:FeatureCollection ...
Document generated by Confluence on Jan 16, 2008 23:27